package gewu.suleju.dao.iml;

import gewu.suleju.model.pojo.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface IUserDao extends JpaRepository<User,Integer> {
    User findByEmail(String email);
    User findByPhone(String phone);
    //查找用户名
    User findUserByUsername(String username);
    User findUserById(Integer id);
    @Transactional
    @Modifying
    @Query(value="update user set username = ?1 ,phone = ?2 where id = ?3",nativeQuery = true)
    void updateUser(String nameName, String phone, Integer id);

    @Transactional
    @Modifying
    @Query(value="update user set username= ?1 ,password = ?2,phone=?3,email =?4 where id = ?5",nativeQuery = true)

    void updateUserDeAll(String username,String password,String phone,String email,Integer id);
}